#!/usr/local/bin/perl -w
use strict;
use utf8;
use lib '../lib';

use NG::Sys::App 'NG::Sys::Loop::Run';
use NG::Chat::Client::Admin;
use Time::HiRes qw(sleep);
use NG::Sys::Average;

my $app = new NG::Sys::App(logger=>"screen");
$app->die_to_logger;
$app->warn_to_logger;

my $avg = new NG::Sys::Average(len => 100);
$app->run;

sub on_process {
	my ($self,$queue) = @_;
	my $count = 0;
	while(1){
		$queue->send_message({cmd => "echo", text => ++$count});
		$avg->count;
		if($avg->check(5)){
			print $avg->speed,"\n";
		}
		sleep 0.00001 unless $count % 2;
	}
}
sub on_init_process {
	my $self = shift;
	return NG::Chat::Client::Admin->new($self);
}
